package com.data.platform.datasource.autoconfigure;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;


@Configuration
//@EnableConfigurationProperties({ HikariDataSourceProperties.class, DataSourceProperties.class })
@EnableConfigurationProperties({ DataSourceProperties.class })
public class DataSourceConfiguration {
    @Autowired
    private DataSourceProperties dataSourceProperties;
//    @Autowired
//    private HikariDataSourceProperties hikariDataSourceProperties;

//    @Bean
//    @RefreshScope
////    @ConditionalOnProperty(name = "mybatis-plus-hikari", value = "enabled", havingValue = "true")
//    public HikariDataSource dataSource() {
//        HikariDataSource dataSource = new HikariDataSource();
//        dataSource.setDriverClassName(dataSourceProperties.getDriverClassName());
//        dataSource.setJdbcUrl(dataSourceProperties.getUrl());
//        dataSource.setUsername(dataSourceProperties.getUsername());
//        dataSource.setPassword(dataSourceProperties.getPassword());
////        String connectionProperty = hikariDataSourceProperties.getConnectionProperties();
////        String[] connectionProperties = connectionProperty.split(";");
////        Properties properties = new Properties();
////        for (String property: connectionProperties) {
////            String[] strings = property.split("=");
////            properties.setProperty(strings[0], strings[1]);
////        }
////        dataSource.setDataSourceProperties(properties);
//        return dataSource;
//    }
}
